Home |
| Latest | About | Random
# Drawing answers. Draw a square. ```cpp #include #include using namespace std; int main() { int n; cout << "Enter size of square: "; cin >> n; for (int i = 0; i < n; ++i) { cout << "*"; } cout << endl; for (int i = 0; i < n-2; ++i) { cout << "*"; for (int i = 0; i < n-2; ++i) { cout << " "; } cout << "*" << endl; } for (int i = 0; i < n; ++i) { cout << "*"; } cout << endl; return 0; } ``` Draw a circle ```cpp #include #include using namespace std; int main() { int n; cout << "Enter size of circle: "; cin >> n; for (int x = 0; x < n; ++x) { for (int y = 0 ; y < n; ++y) { if (pow(x-n/2, 2) + pow(y-n/2,2) < pow(n/2,2)) { cout << "*"; } else { cout << " "; } } cout << endl; } cout << endl; return 0; } ```